//
// Created by Jisam on 2024/5/28.
//
#include <iostream>
#include <vector>
#include <queue>
#include <climits>

using namespace std;

// 图的邻接表表示
vector<vector<pair<int, int>>> graph;

// Dijkstra算法修改版，用于检查是否存在一条路径，其最大权重不超过maxWeight
bool dijkstra(int s, int t, int maxWeight) {
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    vector<int> dist(graph.size(), INT_MAX);

    pq.push({0, s});
    dist[s] = 0;

    while (!pq.empty()) {
        int u = pq.top().second;
        pq.pop();

        for (auto& edge : graph[u]) {
            int v = edge.first;
            int weight = edge.second;

            // 只考虑权重小于等于maxWeight的边
            if (weight <= maxWeight) {
                int newDist = max(dist[u], weight);
                if (newDist < dist[v]) {
                    dist[v] = newDist;
                    pq.push({newDist, v});
                }
            }
        }
    }

    // 如果目标节点的距离不是无穷大，则说明存在路径
    return dist[t] != INT_MAX;
}

// 二分搜索来确定最小瓶颈路的值
int binarySearch(int s, int t) {
    int low = 0;
    int high = INT_MAX;
    int ans = INT_MAX;

    while (low <= high) {
        int mid = low + (high - low) / 2;
        if (dijkstra(s, t, mid)) {
            ans = mid;
            high = mid - 1;
        } else {
            low = mid + 1;
        }
    }

    return ans;
}

int main() {
    // 假设图已经通过某种方式构建并存储在graph中
    // graph[i]存储节点i的所有邻接节点和对应的边的权重

    int s, t;
    // s是刘禅的起始位置，t是水晶的位置
    cin >> s >> t;

    // 执行二分搜索来找到最小瓶颈路的值
    int minBottleneckWeight = binarySearch(s, t);

    cout << minBottleneckWeight << endl;

    return 0;
}
